﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace FzWeb.Filter
{
    public class ExceptionFilter : FilterAttribute, IExceptionFilter
    {
        #region IExceptionFilter 成员

        void IExceptionFilter.OnException(ExceptionContext filterContext)
        {   
            filterContext.Controller.ViewData["ErrorMessage"] = filterContext.Exception.Message;
            filterContext.Result = new ViewResult()
            {
               ViewName = "Error",
               ViewData = filterContext.Controller.ViewData,
            };      
            
            filterContext.ExceptionHandled = true;
        }

        #endregion
    }
}
